home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / BORL_TIP / TI2000 / TI2709.ASC < prev    next >
Text File  |  1994-10-03  |  3KB  |  86 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.   PRODUCT  :  Pascal                                 NUMBER  :  2709
  8.   VERSION  :  All
  9.        OS  :  DOS
  10.      DATE  :  September 28, 1994                       PAGE  :  1/2
  11.  
  12.     TITLE  :  Accessing more than 15 files from your DOS app.
  13.  
  14.  
  15.  
  16.  
  17. DOS imposes a limit of 20 open files for any one program.  DOS, friendly
  18. as it is, uses 5 of these file handles internally - leaving your 
  19. application with only 15 available file handles.  Fortunately, the 15-
  20. file barrier is easily broken.  Just add the GetMoreHandles() function to
  21. your application, and call it in the beginning of your program, passing it
  22. the number of handles you would like your application to have available.
  23. The number you pass must be in the range of 20 to 255, and it must not
  24. exceed the number specified in the FILES= statement of your CONFIG.SYS.
  25.  
  26.  
  27. uses DOS;
  28.  
  29. function GetMoreHandles(NumHandles: Word): Boolean;
  30. {
  31.   NumHandles is the number of file handles you want your application
  32.   to have available.  If an error occurs, function will return False,
  33.   and any DOS error will be reported in the DOSError global variable.
  34.   NOTE: NumHandles must be less than or equal to the number specified
  35.   in the FILES= statement in your CONFIG.SYS.
  36. }
  37. Var
  38.   ReturnVal: Boolean;
  39. begin
  40.   ReturnVal := True;   { assume success }
  41.   { Check to make sure DOS version is greater than 3.3 }
  42.   if (((DOSVersion and $00FF) = 3) and ((DOSVersion and $FF00) < 3)) or
  43.      ((DOSVersion and $00FF) < 3) then ReturnVal := False;
  44.   { Can't allocate more than 255 or less than 20 handles }
  45.   if (NumHandles > 255) or (NumHandles < 20) then ReturnVal := False;
  46.   if ReturnVal then asm
  47.     mov ax, 6700h           { function 67h }
  48.     mov bx, NumHandles      { requested handles in bx }
  49.     int 21h                 { DOS call }
  50.     jae @@NotAnError        { CF set on error }
  51.     mov ReturnVal, 00h      { return false on error }
  52.     mov DOSError, ax        { ax contains the error code }
  53.     @@NotAnError:
  54.   end;
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.   PRODUCT  :  Pascal                                 NUMBER  :  2709
  68.   VERSION  :  All
  69.        OS  :  DOS
  70.      DATE  :  September 28, 1994                       PAGE  :  2/2
  71.  
  72.     TITLE  :  Accessing more than 15 files from your DOS app.
  73.  
  74.  
  75.  
  76.  
  77.   GetMoreHandles := ReturnVal;
  78. end;
  79.  
  80.  
  81.  
  82. DISCLAIMER: You have the right to use this technical information
  83. subject to the terms of the No-Nonsense License Statement that
  84. you received with the Borland product to which this information
  85. pertains.
  86.